<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>黑龙江省科技资源信息管理系统</title>
<base href="<%=basePath%>" />
<link href="css/css.css" rel="stylesheet" type="text/css" />
<link href="css/select.css" rel="stylesheet" type="text/css" />
<script src="js/tab.js"></script>
<!-- <script src="http://api.map.baidu.com/api?v=1.3" type="text/javascript"></script> -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=gkhZkvMMhPRMs1ybtbM7nmhH1ryHr6Dp"></script>
<link type="text/css" href="css/cupertino/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="js/searchInRectangle.js"></script>
</head>
<body onload="initMap();">
	<div id="main">
		<div class="top">
			<div class="logo">
				<a href="#"><img src="images/logo.jpg" width="360" height="85" /> </a>
			</div>
			<div class="search">
				<div class="sea_con">
					<ul class="list">
						<li><a id='a2' href="instrument/dxyq.ins">仪器信息</a></li>
						<li><a id='a2' href="institution/dw.ins">机构信息</a></li>
						<li><a id='a2' href="project/xm.ins">检测项目</a></li>
						<li><a id='a2' href="talent/ry.ins">人才信息</a></li>
						<!-- 						<li><a id='a2' href="result/cg.ins">成果信息</a></li> -->
						<li class="current"><a id='a2' href="base/syjd.ins">基地信息</a></li>
						<!-- 						<li><a id='a2' href="analysis/fx.ins">测试分析</a></li> -->
					</ul>
				</div>
			</div>
		</div>
		<div class="content">
			<div class="left" id="left">
				<p class="act_top" id="tab_search">
					<a href="base/syjdcx.ins" id="search1_list" onclick="tabs3('search',1,2,'list')">内容搜索</a> <a href="base/syjd.ins" id="search2_list" onclick="tabs3('search',2,2,'list')" class="current">统计信息</a>
				</p>
				<!--显示弹出框-->
				<div class="table_action" id="height">
					<div class="table_list1 table_list" id="news_cont1_list" style="display: none">
						<div class="table_text">
							<div class="button">
								<a href="javaScript:void(0)" onclick="closeDis();" class="button_a"> 关闭 </a> <a href="javaScript:void(0)" class="button_a" id="fanhui" onclick="window.history.back();"> 返回 </a> <a
									href="javaScript:void(0)" class="button_a" id="dayin" onclick="printiframe()"> 打印 </a>
							</div>
							<div class="iframe_table">
								<iframe id="iframe" name="layer_iframe" src="" scrolling="yes" height="100%" width="615px" frameborder="0"></iframe>
							</div>
						</div>
					</div>
					<div id="search_cont1_list">
						<div class="title_nav2" id="search_cont1_list">
							<div class="t_n" style="width: 212px;">
								<p class="tn_t">
									<a href="javaScript:void(0)" class="current" id="navt1_list" onclick="return changeZb('type',1,3)">基地类别</a>
								</p>
							</div>
							<div class="t_n" style="width: 212px;">
								<p class="tn_t">
									<a href="javaScript:void(0)" id="navt2_list" onclick="return changeZb('level',2,3)">基地级别</a>
								</p>
							</div>
							<div class="t_n" style="width: 212px;">
								<p class="tn_t">
									<!-- 									<a href="javaScript:void(0)" id="navt3_list" onclick="return changeZbAndDisplaydetail('sum',3,3)">分布汇总</a> -->
									<a href="javaScript:void(0)" id="navt3_list" onclick="window.location.href='base/indexAnalysis.ins'">指数分析</a>
								</p>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!--对比弹出框 -->
			<div id="dialog" title="数据比较"></div>
			<div class="con_right" id="right">
				<div class="r_top">
					<a href="javascript:pr()" class="sj_icon"><img id="xs" src="images/icon.jpg" /> </a>
					<p class="city_f" id="curzt"></p>
					<p class="city_l" id="tl"></p>
				</div>
				<div class="map">
					<div id="container" style="width: 100%; height: 700px;"></div>
				</div>
			</div>
			<!--main end-->
		</div>
	</div>


	<script>
		//初始化参数
		var map = null;
		var curlevel = null;
		var curcenterlng = null;
		var curcenterlat = null;
		var tx = null;
		var ty = null;
		var laiyuan = null;
		var zhibiao = null;
		var tongji = null;

		/*
		初始化地图
		 */
		function initMap() {
			//获取地理信息相关的参数
			if (
	<%=session.getAttribute("curlevel")%>
		!= null)
				curlevel =
	<%=session.getAttribute("curlevel")%>
		;
			if (
	<%=session.getAttribute("curcenterlng")%>
		!= null)
				curcenterlng =
	<%=session.getAttribute("curcenterlng")%>
		;
			if (
	<%=session.getAttribute("curcenterlat")%>
		!= null)
				curcenterlat =
	<%=session.getAttribute("curcenterlat")%>
		;

			//若session中为空，则初始化为默认的缩放层级及坐标
			if (curlevel == null) {
				curlevel = 6;
			}
			if (curcenterlng == null) {
				curcenterlng = 128.91077;
			}
			if (curcenterlat == null) {
				curcenterlat = 48.734684;
			}

			//创建地图
			map = new BMap.Map("container", {
				minZoom : 5
			});
			var point = new BMap.Point(curcenterlng, curcenterlat); // 创建点坐标   
			map.centerAndZoom(point, curlevel); // 初始化地图，设置中心点坐标和地图级别

			//地图控件
			map.enableScrollWheelZoom(); // 开启鼠标滚轮缩放   
			map.enableKeyboard(); // 开启键盘控制   
			map.enableContinuousZoom(); // 开启连续缩放效果   
			map.enableInertialDragging(); // 开启惯性拖拽效果
			map.enableDragging(); //开启拖拽效果  
			map.addControl(new BMap.NavigationControl({
				type : BMAP_NAVIGATION_CONTROL_ZOOM
			}));
			map.addControl(new BMap.ScaleControl());
			// 	  map.addControl(new BMap.OverviewMapControl());   
			map.addControl(new BMap.MapTypeControl({
				mapTypes : [ BMAP_NORMAL_MAP, BMAP_HYBRID_MAP ]
			}));

			//监听缩放
			map.addEventListener("zoomend", function() {
				//获取当前地图层级
				var zoomlevel = map.getZoom();
				//按省市级别查找
				if (zoomlevel <= 7) {
					findDxyq("province");
				}

				//按城市级别查找
				if (zoomlevel == 8) {
					findDxyq("city");
				}
				//按县级别查找
				if (zoomlevel == 9) {
					findDxyq("xian");
				}

				//按单位级别查找
				if (zoomlevel >= 10) {
					findDxyq("danwei");
				}
			});

			draw('type');

		}

		function changeZb(zhibiao, i, n) {
			for (j = 1; j <= n; j++)
				if (j == i)
					$("#navt" + j + "_list").attr("class", "current");
				else
					$("#navt" + j + "_list").attr("class", "");
			ChangeSession(zhibiao);
			return false;
		}

		function ChangeSession(zhibiao) {
			draw(zhibiao);
			return false;
		}

		function draw(zhibiaotype) {
			zhibiao = zhibiaotype;
			//alert(zhibiao);
			if (curlevel <= 7) {
				findDxyq("province");
			}
			//按城市级别查找
			if (curlevel == 8) {
				findDxyq("city");
			}
			//按县级别查找
			if (curlevel == 9) {
				findDxyq("xian");
			}
			//按单位级别查找
			if (curlevel >= 10) {
				findDxyq("danwei");
			}
		}

		function changeCurZtAndtl(loctype) {
			if (loctype == "province") {
				$("#curzt")
						.html(
								"<a href=\"#\" onclick=\"return findQuyu('province')\"><font color='red'>省</font></a>>><a href=\"#\" onclick=\"return findQuyu('city')\">市</a>>><a href=\"#\" onclick=\"return findQuyu('xian')\">区县</a>>><a href=\"#\" onclick=\"return findQuyu('danwei')\">单位</a>");
				$("#tl")
						.html(
								"<a ><img src = 'image/red.gif' width=12  height=15/>100个以上<img src = 'image/blue.gif' width=12  height=15/>50个到100个<img src = 'image/green.gif' width=12  height=15/>0个到50个</a>");
			}
			if (loctype == "city") {
				$("#curzt")
						.html(
								"<a href=\"#\" onclick=\"return findQuyu('province')\">省</a>>><a href=\"#\" onclick=\"return findQuyu('city')\"><font color='red'>市</font></a>>><a href=\"#\" onclick=\"return findQuyu('xian')\">区县</a>>><a href=\"#\" onclick=\"return findQuyu('danwei')\">单位</a>");
				$("#tl")
						.html(
								"<a ><img src = 'image/red.gif' width=12  height=15/>100个以上<img src = 'image/blue.gif' width=12  height=15/>50个到100个<img src = 'image/green.gif' width=12  height=15/>0个到50个</a>");
			}
			if (loctype == "xian") {
				$("#curzt")
						.html(
								"<a href=\"#\" onclick=\"return findQuyu('province')\">省</a>>><a href=\"#\" onclick=\"return findQuyu('city')\">市</a>>><a href=\"#\" onclick=\"return findQuyu('xian')\"><font color='red'>区县</font></a>>><a href=\"#\" onclick=\"return findQuyu('danwei')\">单位</a>");
				$("#tl")
						.html(
								"<a ><img src = 'image/red.gif' width=12  height=15/>50个以上<img src = 'image/blue.gif' width=12  height=15/>10个到50个<img src = 'image/green.gif' width=12  height=15/>0个到10个</a>");
			}
			if (loctype == "danwei") {
				$("#curzt")
						.html(
								"<a href=\"#\" onclick=\"return findQuyu('province')\">省</a>>><a href=\"#\" onclick=\"return findQuyu('city')\">市</a>>><a href=\"#\" onclick=\"return findQuyu('xian')\">区县</a>>><a href=\"#\" onclick=\"return findQuyu('danwei')\"><font color='red'>单位</font></a>");
				$("#tl").html("");
			}
		}

		function findQuyu(loctype) {
			if (loctype == "danwei") {
				curlevel = 10;
			}
			if (loctype == "province") {
				curlevel = 7;
			}
			if (loctype == "city") {
				curlevel = 8;
			}
			if (loctype == "xian") {
				curlevel = 9;
			}
			map.centerAndZoom(map.getBounds().getCenter(), curlevel); // 初始化地图，设置中心点坐标和地图级别
			map.clearOverlays();
			return false;
		}

		//====================前五个层级=================================================

		function findDxyq(loctype) {
			changeCurZtAndtl(loctype);
			curlevel = map.getZoom();
			curcenterlng = map.getCenter().lng;
			curcenterlat = map.getCenter().lat;
			map.clearOverlays();
			getBoundary();//圈出广东省 
			sendRequestPost("base/getSum.ins", "zhibiao=" + zhibiao
					+ "&curlevel=" + curlevel + "&curcenterlng=" + curcenterlng
					+ "&curcenterlat=" + curcenterlat + "&loctype=" + loctype);
		}

		var xmlHttpRequest;
		//请求函数
		function sendRequestPost(url, param) {
			xmlHttpRequest = createXMLHttpRequest();
			xmlHttpRequest.open("POST", url, true);
			xmlHttpRequest.setRequestHeader("Content-Type",
					"application/x-www-form-urlencoded");
			xmlHttpRequest.onreadystatechange = processResponse;
			xmlHttpRequest.send(param);
		}
		/*
		处理返回信息函数
		 */
		function processResponse() {
			if (xmlHttpRequest.readyState == 4) {
				if (xmlHttpRequest.status == 200) {
					var res = xmlHttpRequest.responseText;
					var locations = res.split("|");
					for (i = 0; i < locations.length; i++) {
						var temp = locations[i].split(",");
						temp[4] = temp[4].replace(/(^\s*)|(\s*$)/g, "");
						showPoint(temp[0], temp[1], temp[2], temp[3], temp[4]);
					}
				}
			}
		}
		/*
		显示当前信息窗口
		 */
		function showPoint(x, y, shuliang, quyu, loctype) {
			//根据数量获取对应的图例    
			var image = getImage(shuliang, loctype, "gdsyjd");
			var myIcon = new BMap.Icon(image, new BMap.Size(20, 25), {
				anchor : new BMap.Size(15, 5)
			});
			var point = new BMap.Point(x, y);
			var marker = new BMap.Marker(point, {
				icon : myIcon
			});
			var title = null;
			if (loctype == "city" || loctype == "xian")
				title = "<h><strong>" + quyu + " 实验基地信息统计</strong></h>"
						+ "<a id=" + quyu
						+ "  href='javascript:void(0)'  onclick=change('"
						+ quyu + "','" + loctype
						+ "','hljsyjd'); class='button_a'>加入比较</a><br>";
			else if (loctype == "province")
				title = "<h><strong>"
						+ quyu
						+ " 实验基地信息统计</strong></h>"
						+ "<a href='javascript:void(0)'  onclick=displayby('city','gdsyjd'); class='button_a'>按市排序</a>"
						+ "<a href='javascript:void(0)'  onclick=displayby('danwei','gdsyjd'); class='button_a'>按单位排序</a>"
						+ "<br>";
			else
				title = "<h><strong>" + quyu + " 实验基地信息统计</strong></h><br>";

			if (tx == x && ty == y) {
				var opts = {
					width : 600, // 信息窗口宽度   
					height : 440, // 信息窗口高度   
					title : title
				// 信息窗口标题   
				}
				var message = "<table  width=100%  align=left><tr align=left><td>实验基地个数:</td><td><a href='javascript:void(0)' onclick=\"return displaydetail('"
						+ loctype
						+ "','"
						+ quyu
						+ "')\">"
						+ shuliang
						+ "个   </a></td></tr>";
				var httprequest = createXMLHttpRequest();
				httprequest.open("post", "base/getCount.ins", true);
				httprequest.setRequestHeader("Content-Type",
						"application/x-www-form-urlencoded");
				httprequest.onreadystatechange = function() {
					if (httprequest.readyState == 4) {
						if (httprequest.status == 200) {
							var res = httprequest.responseText;
							var window = new BMap.InfoWindow(
									message
											+ "<tr><td colspan='2'><img id='tu' src= '"+res+ "'></img></td></tr></table>",
									opts);
							window.addEventListener("clickclose", function() {
								tx = 0;
								ty = 0;
							});
							map.openInfoWindow(window, point);
						}
					}
				};
				httprequest.send("quyu=" + quyu + "&loctype=" + loctype
						+ "&zhibiao=" + zhibiao);
			}

			marker
					.addEventListener(
							"click",
							function() {
								var opts = {
									width : 600, // 信息窗口宽度   
									height : 440, // 信息窗口高度   
									title : title
								// 信息窗口标题   
								}
								tx = x;
								ty = y;
								var message = "<table  width=100%  align=left><tr align=left><td>实验基地个数:</td><td><a href='javascript:void(0)' onclick=\"return displaydetail('"
										+ loctype
										+ "','"
										+ quyu
										+ "')\">"
										+ shuliang + "个   </a></td></tr>";
								var httprequest = createXMLHttpRequest();
								httprequest.open("post", "base/getCount.ins",
										true);
								httprequest.setRequestHeader("Content-Type",
										"application/x-www-form-urlencoded");
								httprequest.onreadystatechange = function() {
									if (httprequest.readyState == 4) {
										if (httprequest.status == 200) {
											var res = httprequest.responseText;
											var window = new BMap.InfoWindow(
													message
															+ "<tr><td colspan='2'><img id='tu' src= '"+res+ "'></img></td></tr></table>",
													opts);
											window.addEventListener(
													"clickclose", function() {
														tx = 0;
														ty = 0;
													});
											map.openInfoWindow(window, point);
										}
									}
								};
								httprequest.send("quyu=" + quyu + "&loctype="
										+ loctype + "&zhibiao=" + zhibiao);
							});
			map.addOverlay(marker);
		}
		function displaydetail(loctype, quyu) {
			var src = "base/syjdcountlist.ins?quyu=" + quyu + "&loctype="
					+ loctype + "&zhibiao=" + zhibiao;
			$("#iframe").attr("src", encodeURI(src));
			$("#news_cont1_list").show("slow");
			return false;
		}
		function changeZbAndDisplaydetail(zhibiao, i, n) {
			// changeZb
			for (j = 1; j <= n; j++)
				if (j == i)
					$("#navt" + j + "_list").attr("class", "current");
				else
					$("#navt" + j + "_list").attr("class", "");
			ChangeSession(zhibiao);
			// displayDetail
			var src = "hlj/hljlayer/syjdsum.jsp";
			$("#iframe").attr("src", encodeURI(src));
			$("#news_cont1_list").show("slow");
			return false;
		}
	</script>
</body>
</html>
